import React from 'react'
import { View, Text } from '@tarojs/components'
import './Popup.scss'

interface PopupProps {
  visible: boolean
  title: string
  onClose: () => void
  children?: React.ReactNode
}

const Popup: React.FC<PopupProps> = ({ visible, title, onClose, children }) => {
  if (!visible) return null

  return (
    <View className="popup-mask">
      <View className="popup-content">
        <Text className="popup-title">{title}</Text>
        <View className="popup-body">{children}</View>
      </View>
      <View className="popup-close" onClick={onClose}></View>
    </View>
  )
}

export default Popup
